<?php

$oDb =& Database::get();
$oTpl =& App::getTemplate();
$oReq =& App::getRequest();

$aErrors = array();

if ($oReq->get('go'))
{
	$aVal = $oReq->get('val');
	$aVal['version'] = App::getParam('info.version');
	if (empty($aVal['code']) || empty($aVal['block'])) 
	{
		$aErrors[] = App::format('Mod_Admin.missing_varname_block');
	}
	else
	{
		$aVal['val_backup'] = $aVal['val'];
		$oDb->insert(App::getT('sys_sett'), $aVal);
		$oDb->insert(App::getT('language_phrase'), array('languageid' => 1, 'varname' => 'Mod_Admin.param.' . $aVal['code'], 'text' => $oReq->get('phrase'), 'product' => 'konsort', 'time' => time(), 'version' => App::getParam('info.version'), 'module' => 'Mod_Admin', 'default' => 'Mod_Admin.param.' . $aVal['code']));
		$oLang =& App::getLanguage();
		$oLang->removeCachedFiles();
		Cache::rmFile('config.php');
		App::gotoUrl('admin.config.add', array(), 'Added!');
	}
}

$oTpl->assign(array(
	'aErr' => $aErrors,
));

?>